package com.gg.haoqi.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.gg.haoqi.R;
import com.gg.haoqi.bean.YjsList;
import com.gg.haoqi.utils.ImageLoaderUtils;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by LW on 2015/11/11.
 */
public class TenAdapter extends AppBaseAdapter<YjsList> {

    public TenAdapter(List<YjsList> list, Context context) {
        super(list, context);
    }

    @Override
    public ViewHolder getViewHolder(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = AppBaseAdapter.ViewHolder.get(context, convertView, parent, R.layout.item_ten_list);

        ImageView iv = (ImageView) holder.findViewById(R.id.item_ten_img);

        ImageView ivCamera = (ImageView) holder.findViewById(R.id.item_ten_camera);

        TextView category = (TextView) holder.findViewById(R.id.item_ten_category);

        TextView title = (TextView) holder.findViewById(R.id.item_ten_title);

        TextView comment = (TextView) holder.findViewById(R.id.item_ten_comment);

        TextView like = (TextView) holder.findViewById(R.id.item_ten_like);

        ImageLoader.getInstance().displayImage(list.get(position).getImage(), iv, ImageLoaderUtils.getDisplayImageLoader());
        ImageLoader.getInstance().displayImage(list.get(position).getPost().getCategory().getWhite_image(), ivCamera, ImageLoaderUtils.getDisplayImageLoader());

        if (list.get(position).getPost().getSuper_tag()!=null)
            category.setText(list.get(position).getPost().getCategory().getTitle() + "." + list.get(position).getPost().getSuper_tag());
        else
            category.setText(list.get(position).getPost().getCategory().getTitle());

        title.setText(list.get(position).getPost().getTitle());

        comment.setText(list.get(position).getPost().getComment_count()+"");

        like.setText(list.get(position).getPost().getPraise_count()+"");

        return holder;
    }
}
